cd "C:\Users\SThontwa\Desktop\Paper 1 Submission\Data"

* 1) DATA PREPARATION. Please ensure that the dataset Survey1, Survey2 and Survey3 are located in the main folder along the dofile. 
  //Some commands may jump depending on the version of Stata used (ie : outreg2 unrecongized). Should this happen, please install the command in question and continue running the do file (ie: ssc install outreg2)
  //Results tables are automatically and respectively saved in the main folder as an excel file labeled 'Tables.xlsx'. 
global S RIZ MAIS MANIOC SUCRE HUILE

forvalues i=1/3 {

//========================= Individual characteristics =======================//
import excel "Survey`i'.xlsx", sheet("Main") allstring clear

* Drop the columns with all missing values
dropmiss, force

* Remove some characteristics in row 1, and use it as the variable name
foreach v of varlist * {
qui replace `v'=subinstr(`v'," ","_",.) in 1
qui replace `v'=subinstr(`v',"(","",.)  in 1
qui replace `v'=subinstr(`v',")","",.)  in 1
qui replace `v'=subinstr(`v',".","_",.)  in 1
rename `v' `=`v'[1]'
}

* Use row 2 or 3 as the variable label
foreach v of varlist * {
replace `v'=`v'[_n-1] if `v'[2]~="" in 3
}
foreach v of varlist * {
local vtext=`v'[3]
label var `v' "`vtext'"
}
drop in 1/3

egen Age=group(IDENT_02), label
label var Age "Age of the respondent"

replace IDENT_03="Male" if IDENT_03=="Homme"
replace IDENT_03="Female" if IDENT_03=="Femme"
egen Gender=group(IDENT_03), label
label var Gender "Gender of the respondent"

gen Marital=1 if IDENT_04=="Celibataire"
replace Marital=2 if IDENT_04=="Marie(e)"
replace Marital=3 if IDENT_04=="Divorce(e)"
replace Marital=4 if IDENT_04=="Veuf ou Veuve" | IDENT_04=="Autres"
label define Marital 1 "Single" 2 "Married" 3 "Divorced" 4 " Widow or other", replace
label value Marital Marital
label var Marital "Marital status of the respondent"

gen Education=1 if IDENT_05=="Education Primaire" | IDENT_05=="Education Secondaire"
replace Education=2 if IDENT_05=="Niveau Universitaire Graduat" | IDENT_05=="Niveau Universitaire Licence"
replace Education=3 if IDENT_05=="Master" | IDENT_05=="Doctorat ou PhD"
replace Education=4 if IDENT_05=="Autres"
label define Education 1 "Primary or secondary" 2 "Undergraduate" 3 "Higher education" 4 "Other"
label value Education Education
label var Education "Highest education of the respondent"

egen StudyArea=group(IDENT_06), label
label var StudyArea "Study area of the respondent"

destring HH_02_2, gen(ChildNum) force
destring HH_03_1, gen(Child6) force
replace HH_01="Yes" if HH_01=="Oui" 
replace HH_01="No" if HH_01=="Non"
egen Child=group(HH_01), label
label var Child "Respondent has children"
label var ChildNum "Number of respndent's children"
label var Child6 "Number of respndent's children under 6"

gen     Salary=1 if ECON_07=="$1- $100" | ECON_07=="$101 -  $150" | ECON_07=="$151 - $250" | ECON_07=="$251 - $500"
replace Salary=2 if ECON_07=="$501-$1000"
replace Salary=3 if ECON_07=="$1001- $1500" | ECON_07=="$1501-$2000" | ECON_07=="$2001-$2500" | ECON_07=="$2501- $3000" | ECON_07=="$3001- $4000" | ///
                    ECON_07=="$4001- $5000" | ECON_07=="$9001- $1000" | ECON_07=="Autres"

gen     SalaryC=50 if ECON_07=="$1- $100" 
replace SalaryC=125 if ECON_07=="$101 -  $150"
replace SalaryC=200 if ECON_07=="$151 - $250"
replace SalaryC=375 if ECON_07=="$251 - $500"
replace SalaryC=750 if ECON_07=="$501-$1000"
replace SalaryC=1250 if ECON_07=="$1001- $1500"
replace SalaryC=1750 if ECON_07=="$1501-$2000"
replace SalaryC=2250 if ECON_07=="$2001-$2500"
replace SalaryC=2750 if ECON_07=="$2501- $3000"
replace SalaryC=3500 if ECON_07=="$3001- $4000"
replace SalaryC=4500 if ECON_07=="$4001- $5000"
replace SalaryC=9500 if ECON_07=="$9001- $1000"
replace SalaryC=10000 if ECON_07=="Autres" 					
label define Salary 1 "$1-$500" 2 "$501-$1000" 3 "$1000+", replace
label value Salary Salary
label var Salary "Respondent's monthly income"
label var SalaryC "Respondent's monthly income"

replace ECON_01="Yes" if ECON_01=="Oui" 
replace ECON_01="No" if ECON_01=="Non"
egen Employment=group(ECON_01), label
label var Employment "Employment status"

destring LocationLatitude LocationLongitude, replace force

egen District=group(ECON_09), label
label var District "Respondent's district"

egen ShopingLocation=group(ECON_10), label
label var ShopingLocation "Respondent's shoping location"

gen 	Meals=1 if ECON_08=="Une fois par jour"  
replace Meals=2 if ECON_08=="Deux fois par jour"
replace Meals=3 if ECON_08=="Trois fois par jour"
replace Meals=4 if ECON_08=="Autres"
replace Meals=5 if ECON_08=="Je prefere de ne ne pas repondre"
label define Meals 1 "Once a day" 2 "Twice a day" 3 "Three times a day" 4 "Other" 5 "No answer"
label value Meals Meals
label var Meals "Number of meals per day"

keep Person_ID Age Gender Marital Education StudyArea Child ChildNum Child6 Salary SalaryC Employment LocationLatitude LocationLongitude District ShopingLocation Meals
destring Person_ID, replace
sort Person_ID
save Characteristics, replace

//========================= Choice_Cards =====================================//
* Remove some characteristics in row 2, and use it as the variable name
foreach s in $S {
import excel "Survey`i'.xlsx", sheet("Coding_`s' Choice_Cards") allstring clear
foreach v of varlist * {
qui replace `v'=subinstr(`v'," ","_",.) in 2
qui replace `v'=subinstr(`v',"'","",.)  in 2
}
foreach v of varlist * {
rename `v' `=`v'[2]'
}
* Use row 1 as the variable label
foreach v of varlist * {
local vtext=`v'[1]
label var `v' "`vtext'"
}
drop in 1/2

* Harmonize variable names among different products
local done 0 
capture confirm var Respondents 
if _rc == 0  & !`done' { 
rename Respondents Respondent 
local done = 1 
}
local done 0 
foreach var in Choice_cards_or_choice_sets Choice_cars_or_Choice_sets Choice_Cards_or_Choice_set Choice_Cards_or_Choice_Set {
capture confirm var  `var'
if _rc == 0  & !`done' { 
rename `var' Choice_set 
local done = 1 
}
}
local done 0 
capture confirm var Constant 
if _rc == 0  & !`done' { 
rename Constant Const 
local done = 1 
}
gen Product="`s'"
save `s', replace
}
clear
foreach s in $S {
append using `s'
}
foreach s in $S {
erase `s'.dta
}
egen Packaging=group(Emballage), label 
label var Packaging "External decor of product"

gen Dist=1 if strpos(Distance,"20 minutes de marche") | strpos(Distance,"21 minutes de marche")
replace Dist=2 if strpos(Distance,"21 a 45")
replace Dist=3 if strpos(Distance,"de 45 minutes")
label var Dist "Distribution distance"
label define Dist 1 "Walking Distance" 2 "Nearby" 3 "Far", replace
label value Dist Dist

destring Cout, gen(Price) i(P r i x A B C  b c F C :)
label var Price "Price of the product"

replace Origine="Import Regionale" if Origine=="Import regionale"
egen Origin=group(Origine), label
label var Origin "The product origin"
label define Origin 1 "Latin America Import" 2 "Eastern Based Import" 3 "Western Based Import" 4 "Regional Import" 5 "Local", replace
label value Origin Origin
destring Options, gen(Option) 
destring Survey, replace
destring Choice_set, replace
destring cno, replace
keep Packaging Dist Price Origin Option cno Survey Choice_set Product
rename Dist Distance
order Product Survey Choice_set cno
save Coice_cards, replace


//========================= Choice variable ==================================//
foreach product in $S {
import excel "Survey`i'.xlsx", sheet("Main") allstring clear

* Drop the columns with all missing values
dropmiss, force

foreach v of varlist * {
qui replace `v'=subinstr(`v'," ","_",.) in 1
qui replace `v'=subinstr(`v',"(","",.)  in 1
qui replace `v'=subinstr(`v',")","",.)  in 1
qui replace `v'=subinstr(`v',".","_",.)  in 1
rename `v' `=`v'[1]'
}

* Use row 2 or 3 as the variable label
foreach v of varlist * {
replace `v'=`v'[_n-1] if `v'[2]~="" in 3
}
foreach v of varlist * {
local vtext=`v'[3]
label var `v' "`vtext'"
}
drop in 1/3
keep Person_ID `product'*

* Reshape the data to panel
reshape long `product'_, i(Person_ID) j(SurveyFull) string
keep if strpos(`product'_,"Opt")
destring Person_ID, replace
gen Option_chosen=1 if strpos(`product'_,"1")
replace Option_chosen=2 if strpos(`product'_,"2")
sort Person_ID SurveyFull

* Generate Choice variable
expandcl 2, cluster(Person_ID SurveyFull) generate(a)
by Person_ID SurveyFull Option, sort : egen float Option = seq()
gen Choice=0
replace Choice =1 if Option==1 & Option_chosen==1
replace Choice =1 if Option==2 & Option_chosen==2

* Save
keep Person_ID SurveyFull Option Choice Option_chosen
gen Survey=substr(SurveyFull,1,1)
gen cno=substr(SurveyFull,3,1)
destring cno, replace
destring Survey, replace
gen Product="`product'"
save `product', replace
}
clear
foreach product in RIZ MAIS MANIOC SUCRE HUILE {
append using `product'
}
foreach product in RIZ MAIS MANIOC SUCRE HUILE {
erase `product'.dta
}
label define yes 0 "No" 1 "Yes"
label value Choice yes
label var Choice "The option is chosen"
order Product Person_ID SurveyFull Survey Option Option_chosen cno Choice  
save Choice, replace

// ====================== Merging ============================================//
use Choice, clear
joinby Person_ID using Characteristics
joinby Product Survey cno Option using Coice_cards

gen SurveyID="Survey`i'"
order SurveyID Product Person_ID SurveyFull Survey cno Option Option_chosen Choice_set Choice
save Survey`i', replace
}
clear
forvalues i=1/3 {
append using Survey`i'
}
foreach v in Characteristics Choice Coice_cards Survey1 Survey2 Survey3 {
erase `v'.dta
}
replace SurveyID="CG" if SurveyID=="Survey1"
replace SurveyID="IT" if SurveyID=="Survey2"
replace SurveyID="LT" if SurveyID=="Survey3"

foreach v in Packaging Distance Origin  {
quietly tabulate `v', generate(`v')
}
rename Packaging1 Aucun
rename Packaging2 Minimum
rename Packaging3 Moyen
rename Packaging4 Standard

rename Distance1  WalkingDistance
rename Distance2  Nearby
rename Distance3  Far

rename Origin1    LAImport
rename Origin2    EasternImport
rename Origin3    WesternImport
rename Origin4    Regional
rename Origin5    Local

quietly tabulate SurveyID, generate(SurveyID)
rename SurveyID1 CG
rename SurveyID2 IT
rename SurveyID3 LT

egen Education_Gender = group(Education Gender), label
egen Salary_Gender    = group(Salary Gender), label
egen SL_Gender        = group(ShopingLocation Gender), label
egen SL_Salary        = group(ShopingLocation Salary), label

save Final, replace

*RESULT TABLES START HERE. Tables are automatically saved in excel format in the main folder *
* 2) Descriptive analyses

	// Table 2  DESCRIPTIVE STATISTICS
		// Gender
ta Gender SurveyID
bysort Gender: ta SurveyID
bysort SurveyID: ta Gender

		// Marital
ta Marital SurveyID
bysort Marital: ta SurveyID
bysort SurveyID: ta Marital

		// Education
ta Education SurveyID
bysort Education: ta SurveyID
bysort SurveyID: ta Education

		// Child
ta Child SurveyID
bysort Child: ta SurveyID
bysort SurveyID: ta Child

		// Employment
ta Employment SurveyID
bysort Employment: ta SurveyID
bysort SurveyID: ta Employment

		// ShopingLocation
ta ShopingLocation SurveyID
bysort ShopingLocation: ta SurveyID
bysort SurveyID: ta ShopingLocation

	// Table 3 BASELINE REGRESSION. PREFERENCE OF ALL ORIGINS COMPARED TO LOCAL 
use Final, clear
egen obsid = group(SurveyID Product Person_ID SurveyFull)
global ModelSpec Choice Price Minimum Moyen Standard Nearby Far EasternImport WesternImport Regional Local
capture erase Models.txt
foreach s in CG IT LT {
foreach v in RIZ MAIS MANIOC SUCRE HUILE {
clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid)
outreg2 using Models, label ctitle("`s'-`v'")
}
}
import delimited "Models.txt", clear
drop if strpos(v1,"o.")
drop if v3=="" & v4=="" & v5=="" & v6=="" & v7=="" & v8=="" & v9=="" & v10=="" & ///
		v11=="" & v12=="" & v13=="" & v14=="" & v15=="" & v16=="" & v17==""
export excel using "Tables.xlsx", sheet("Table3") sheetreplace
erase Models.txt

	// Table 4 IMPACT OF DIFFERENT ORIGINS ON THE CHOICE OF RESPONDENTS
use Final, clear
global ModelSpec Choice Local IT_Local LT_Local Price Minimum Moyen Standard Nearby Far
global Product RIZ MAIS MANIOC SUCRE HUILE
gen CG_Local=Local*CG
gen IT_Local=Local*IT
gen LT_Local=Local*LT
egen obsid = group(SurveyID Product Person_ID SurveyFull) 
capture erase Models.txt
foreach v in $Product {
clogit $ModelSpec if Product =="`v'", group(obsid) 
outreg2 using Models, label ctitle("`v'")
}
import delimited "Models.txt", clear
drop if strpos(v1,"o.")
drop if v1=="" & v2=="" & v3=="" & v4=="" & v5=="" & v6=="" & v7==""
drop if v3=="-" | v3=="0" | v3=="(0)"
replace v1=subinstr(v1,"1.","",.)
export excel using "Tables.xlsx", sheet("Table4") sheetreplace
erase Models.txt
	
		// Table 5 WILLINGNESS TO PAY FOR LOCAL ORIGIN PRODUCTS ACROSS SURVEY GROUPS
use Final, clear
gen CG_Local=Local*CG
gen IT_Local=Local*IT
gen LT_Local=Local*LT
egen obsid = group(SurveyID Product Person_ID SurveyFull) 

global FILE 1
global ModelSpec Choice Local IT_Local LT_Local Price Minimum Moyen Standard Nearby Far
global Product RIZ MAIS MANIOC SUCRE HUILE
gen IndustrialStandard_yes=0
replace IndustrialStandard_yes=1 if Packaging==3

capture erase WTP.txt
foreach v in $Product {
qui clogit $ModelSpec if Product =="`v'", group(obsid) 
nlcom (_b[Local])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`v'_Local")

qui clogit $ModelSpec if Product =="`v'", group(obsid) 
nlcom (_b[IT_Local])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("IT-`v'_Local")

qui clogit $ModelSpec if Product =="`v'", group(obsid) 
nlcom (_b[LT_Local])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("LT-`v'_Local")
}
import delimited "WTP.txt", clear
replace v1="model" in 2
replace v1="b" in 7
replace v1="se" in 8
replace v1="ci" in 9
drop in 1
drop in 2/5
drop in 5
drop in 6/7
drop v2
sxpose, clear
foreach v of varlist * {
rename `v' `=`v'[1]'
}
drop in 1
export excel using "Tables.xlsx", sheet("Table5") sheetreplace firstrow(variables)
capture erase WTP.txt
	
	// Table 6 WILLINGNESS TO PAY FOR LOCAL ORIGIN ACROSS ATTRIBUTES 
use Final, clear
global ModelSpec Choice Price Minimum Moyen Standard Nearby Far EasternImport WesternImport Regional Local
egen obsid = group(SurveyID Product Person_ID SurveyFull) 

capture erase WTP.txt

foreach s in CG IT LT {
foreach v in RIZ MAIS MANIOC SUCRE HUILE {
	// - Origin
clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[EasternImport])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Origin_EasternImport")

clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[WesternImport])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Origin_WesternImport")

clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[Regional])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Origin_Regional")

clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[Local])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Origin_Local")

if $FILE == 1 {
	// - Packaging
clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[Minimum])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Packaging_Minimum")
}
clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[Moyen])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Packaging_Moyen")

clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[Standard])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Packaging_Standard")

	// - Distance
clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[Nearby])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Distance_Nearby")


clogit $ModelSpec if Product =="`v'" & SurveyID=="`s'", group(obsid) 
nlcom (_b[Far])/- (_b[Price]), post
outreg2 using WTP, stats( coef se ci) se label ctitle("`s'-`v'_Distance_Far")
}
}

	// 3) WTP
import delimited "WTP.txt", clear
replace v1="model" in 2
replace v1="b" in 7
replace v1="se" in 8
replace v1="ci" in 9
drop in 1
drop in 2/5
drop in 5
drop in 6/7
drop v2
sxpose, clear
foreach v of varlist * {
rename `v' `=`v'[1]'
}
drop in 1
export excel using "Tables.xlsx", sheet("Table6") sheetreplace firstrow(variables)
capture erase WTP.txt

	// Table 7. part 1  UPTAKE RATE AND CHANGES IN THE PROBABILITIES OF PREFERENCE STARTING FROM THE BASELINE PRICE TO HIGHER PRICES RANGE FOR EACH PRODUCT 
global ModelSpec Choice Local IT_Local LT_Local Price Minimum Moyen Standard Nearby Far
global Origin Local
use Final, clear
gen CG_Local=Local*CG
gen IT_Local=Local*IT
gen LT_Local=Local*LT
egen obsid = group(SurveyID Product Person_ID SurveyFull) 
gen IndustrialStandard_yes=0
replace IndustrialStandard_yes=1 if Packaging==3

global Product RIZ MAIS MANIOC SUCRE HUILE

capture erase UR.txt
		* - RIZ
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
qui clogit $ModelSpec if Product =="RIZ", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se replace label ctitle("RIZ 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 2000 to 2500
qui clogit $ModelSpec if Product =="RIZ", group(obsid)  
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)) -exp(_b[Price]*2000)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ 2000-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
qui clogit $ModelSpec if Product =="RIZ", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ 3000-5500")

// The change in the probability of choosing the product because of a change in Price from 5000 to 9500
qui clogit $ModelSpec if Product =="RIZ", group(obsid)  
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5000) + exp(_b[Price]*9500)) -exp(_b[Price]*5000)/(exp(_b[Price]*5000) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ 5000-9500")

// Packaged products
clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*1000+_b[IndustrialStandard_yes]) - exp(_b[Price]*1000)) /(exp(_b[Price]*1000) + exp(_b[Price]*1000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_1000")

clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*1500+_b[IndustrialStandard_yes]) - exp(_b[Price]*1500)) /(exp(_b[Price]*1500) + exp(_b[Price]*1500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_1500")

clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*2000+_b[IndustrialStandard_yes]) - exp(_b[Price]*2000)) /(exp(_b[Price]*2000) + exp(_b[Price]*2000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_2000")

clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*2500+_b[IndustrialStandard_yes]) - exp(_b[Price]*2500)) /(exp(_b[Price]*2500) + exp(_b[Price]*2500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_2500")

clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*3000+_b[IndustrialStandard_yes]) - exp(_b[Price]*3000)) /(exp(_b[Price]*3000) + exp(_b[Price]*3000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_3000")

clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*5000+_b[IndustrialStandard_yes]) - exp(_b[Price]*5000)) /(exp(_b[Price]*5000) + exp(_b[Price]*5000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_5000")

clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*5500+_b[IndustrialStandard_yes]) - exp(_b[Price]*5500)) /(exp(_b[Price]*5500) + exp(_b[Price]*5500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_5500")

clogit $ModelSpec IndustrialStandard_yes if Product =="RIZ", group(obsid) 
nlcom (exp(_b[Price]*9500+_b[IndustrialStandard_yes]) - exp(_b[Price]*9500)) /(exp(_b[Price]*9500) + exp(_b[Price]*9500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("RIZ Packaged_9500")

		* - MAIS
// The change in the probability of choosing the product because of a change in Price from 1200 to 1500
qui clogit $ModelSpec if Product =="MAIS", group(obsid)  
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)) -exp(_b[Price]*1200)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS 1200-1500")

// The change in the probability of choosing the product because of a change in Price from 1900 to 2500
qui clogit $ModelSpec if Product =="MAIS", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)) -exp(_b[Price]*1900)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS 1900-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
qui clogit $ModelSpec if Product =="MAIS", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS 3000-5500")

// The change in the probability of choosing the product because of a change in Price from 5500 to 9500
qui clogit $ModelSpec if Product =="MAIS", group(obsid)  
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)) -exp(_b[Price]*5500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS 5500-9500")

// Packaged products
clogit $ModelSpec IndustrialStandard_yes if Product =="MAIS", group(obsid) 
nlcom (exp(_b[Price]*1200+_b[IndustrialStandard_yes]) - exp(_b[Price]*1200)) /(exp(_b[Price]*1200) + exp(_b[Price]*1200+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS Packaged_1200")

clogit $ModelSpec IndustrialStandard_yes if Product =="MAIS", group(obsid) 
nlcom (exp(_b[Price]*1500+_b[IndustrialStandard_yes]) - exp(_b[Price]*1500)) /(exp(_b[Price]*1500) + exp(_b[Price]*1500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS Packaged_1500")

clogit $ModelSpec IndustrialStandard_yes if Product =="MAIS", group(obsid) 
nlcom (exp(_b[Price]*1900+_b[IndustrialStandard_yes]) - exp(_b[Price]*1900)) /(exp(_b[Price]*1900) + exp(_b[Price]*1900+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS Packaged_1900")

clogit $ModelSpec IndustrialStandard_yes if Product =="MAIS", group(obsid) 
nlcom (exp(_b[Price]*2500+_b[IndustrialStandard_yes]) - exp(_b[Price]*2500)) /(exp(_b[Price]*2500) + exp(_b[Price]*2500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS Packaged_2500")

clogit $ModelSpec IndustrialStandard_yes if Product =="MAIS", group(obsid) 
nlcom (exp(_b[Price]*3000+_b[IndustrialStandard_yes]) - exp(_b[Price]*3000)) /(exp(_b[Price]*3000) + exp(_b[Price]*3000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS Packaged_3000")

clogit $ModelSpec IndustrialStandard_yes if Product =="MAIS", group(obsid) 
nlcom (exp(_b[Price]*5500+_b[IndustrialStandard_yes]) - exp(_b[Price]*5500)) /(exp(_b[Price]*5500) + exp(_b[Price]*5500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS Packaged_5500")

clogit $ModelSpec IndustrialStandard_yes if Product =="MAIS", group(obsid) 
nlcom (exp(_b[Price]*9500+_b[IndustrialStandard_yes]) - exp(_b[Price]*9500)) /(exp(_b[Price]*9500) + exp(_b[Price]*9500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MAIS Packaged_9500")

		* - MANIOC
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
qui clogit $ModelSpec if Product =="MANIOC", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 1500 to 2040
qui clogit $ModelSpec if Product =="MANIOC", group(obsid) 
nlcom exp(_b[Price]*2040)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)) -exp(_b[Price]*1500)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC 1500-2040")

// The change in the probability of choosing the product because of a change in Price from 2040 to 5000
qui clogit $ModelSpec if Product =="MANIOC", group(obsid) 
nlcom exp(_b[Price]*5000)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)) -exp(_b[Price]*2040)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC 2040-5000")

// The change in the probability of choosing the product because of a change in Price from 5500 to 9500
qui clogit $ModelSpec if Product =="MANIOC", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)) -exp(_b[Price]*5500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC 5500-9500")	

// Packaged products
clogit $ModelSpec IndustrialStandard_yes if Product =="MANIOC", group(obsid) 
nlcom (exp(_b[Price]*1000+_b[IndustrialStandard_yes]) - exp(_b[Price]*1000)) /(exp(_b[Price]*1000) + exp(_b[Price]*1000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC Packaged_1000")

clogit $ModelSpec IndustrialStandard_yes if Product =="MANIOC", group(obsid) 
nlcom (exp(_b[Price]*1500+_b[IndustrialStandard_yes]) - exp(_b[Price]*1500)) /(exp(_b[Price]*1500) + exp(_b[Price]*1500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC Packaged_1500")

clogit $ModelSpec IndustrialStandard_yes if Product =="MANIOC", group(obsid) 
nlcom (exp(_b[Price]*2040+_b[IndustrialStandard_yes]) - exp(_b[Price]*2040)) /(exp(_b[Price]*2040) + exp(_b[Price]*2040+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC Packaged_2040")

clogit $ModelSpec IndustrialStandard_yes if Product =="MANIOC", group(obsid) 
nlcom (exp(_b[Price]*5000+_b[IndustrialStandard_yes]) - exp(_b[Price]*5000)) /(exp(_b[Price]*5000) + exp(_b[Price]*5000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC Packaged_5000")

clogit $ModelSpec IndustrialStandard_yes if Product =="MANIOC", group(obsid) 
nlcom (exp(_b[Price]*5500+_b[IndustrialStandard_yes]) - exp(_b[Price]*5500)) /(exp(_b[Price]*5500) + exp(_b[Price]*5500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC Packaged_5500")

clogit $ModelSpec IndustrialStandard_yes if Product =="MANIOC", group(obsid) 
nlcom (exp(_b[Price]*9500+_b[IndustrialStandard_yes]) - exp(_b[Price]*9500)) /(exp(_b[Price]*9500) + exp(_b[Price]*9500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("MANIOC Packaged_9500")
	
		* - SUCRE
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
qui clogit $ModelSpec if Product =="SUCRE", group(obsid)  
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
qui clogit $ModelSpec if Product =="SUCRE", group(obsid) 
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
qui clogit $ModelSpec if Product =="SUCRE", group(obsid) 
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
qui clogit $ModelSpec if Product =="SUCRE", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE 4500-7000")

// Packaged products
clogit $ModelSpec IndustrialStandard_yes if Product =="SUCRE", group(obsid) 
nlcom (exp(_b[Price]*1800+_b[IndustrialStandard_yes]) - exp(_b[Price]*1800)) /(exp(_b[Price]*1800) + exp(_b[Price]*1800+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE Packaged_1800")

clogit $ModelSpec IndustrialStandard_yes if Product =="SUCRE", group(obsid) 
nlcom (exp(_b[Price]*2500+_b[IndustrialStandard_yes]) - exp(_b[Price]*2500)) /(exp(_b[Price]*2500) + exp(_b[Price]*2500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE Packaged_2500")

clogit $ModelSpec IndustrialStandard_yes if Product =="SUCRE", group(obsid) 
nlcom (exp(_b[Price]*3500+_b[IndustrialStandard_yes]) - exp(_b[Price]*3500)) /(exp(_b[Price]*3500) + exp(_b[Price]*3500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE Packaged_3500")

clogit $ModelSpec IndustrialStandard_yes if Product =="SUCRE", group(obsid) 
nlcom (exp(_b[Price]*4500+_b[IndustrialStandard_yes]) - exp(_b[Price]*4500)) /(exp(_b[Price]*4500) + exp(_b[Price]*4500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE Packaged_4500")

clogit $ModelSpec IndustrialStandard_yes if Product =="SUCRE", group(obsid) 
nlcom (exp(_b[Price]*7000+_b[IndustrialStandard_yes]) - exp(_b[Price]*7000)) /(exp(_b[Price]*7000) + exp(_b[Price]*7000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("SUCRE Packaged_7000")

		* - HUILE
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
qui clogit $ModelSpec if Product =="HUILE", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
qui clogit $ModelSpec if Product =="HUILE", group(obsid) 
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
qui clogit $ModelSpec if Product =="HUILE", group(obsid) 
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
qui clogit $ModelSpec if Product =="HUILE", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE 4500-7000")

// Packaged products
clogit $ModelSpec IndustrialStandard_yes if Product =="HUILE", group(obsid) 
nlcom (exp(_b[Price]*1800+_b[IndustrialStandard_yes]) - exp(_b[Price]*1800)) /(exp(_b[Price]*1800) + exp(_b[Price]*1800+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE Packaged_1800")

clogit $ModelSpec IndustrialStandard_yes if Product =="HUILE", group(obsid) 
nlcom (exp(_b[Price]*2500+_b[IndustrialStandard_yes]) - exp(_b[Price]*2500)) /(exp(_b[Price]*2500) + exp(_b[Price]*2500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE Packaged_2500")

clogit $ModelSpec IndustrialStandard_yes if Product =="HUILE", group(obsid) 
nlcom (exp(_b[Price]*3500+_b[IndustrialStandard_yes]) - exp(_b[Price]*3500)) /(exp(_b[Price]*3500) + exp(_b[Price]*3500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE Packaged_3500")

clogit $ModelSpec IndustrialStandard_yes if Product =="HUILE", group(obsid) 
nlcom (exp(_b[Price]*4500+_b[IndustrialStandard_yes]) - exp(_b[Price]*4500)) /(exp(_b[Price]*4500) + exp(_b[Price]*4500+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE Packaged_4500")

clogit $ModelSpec IndustrialStandard_yes if Product =="HUILE", group(obsid) 
nlcom (exp(_b[Price]*7000+_b[IndustrialStandard_yes]) - exp(_b[Price]*7000)) /(exp(_b[Price]*7000) + exp(_b[Price]*7000+_b[IndustrialStandard_yes])), post
outreg2 using UR, stats( coef se ci) se label ctitle("HUILE Packaged_7000")

import delimited "UR.txt", clear
replace v1="model" in 2
replace v1="b" in 7
replace v1="se" in 8
replace v1="ci" in 9
drop in 1
drop in 2/5
drop in 5
drop in 6/7
drop v2
sxpose, clear
foreach v of varlist * {
rename `v' `=`v'[1]'
}
drop in 1
export excel using "Tables.xlsx", sheet("Table7_1") sheetreplace firstrow(variables)
capture erase UR.txt

	// Table 7. part 2 CHANGES IN THE PROBABILITIES ACROSS PRICES AND ATTRIBUTE LEVELS
global ModelSpec Choice Price Minimum Moyen Standard Nearby Far EasternImport WesternImport Regional Local

use Final, clear
egen obsid = group(SurveyID Product Person_ID SurveyFull) 
capture erase UR.txt

// 1) SurveyID=="CG"

	// a) Product =="RIZ"
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se replace label ctitle("CG-RIZ 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 2000 to 2500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)) -exp(_b[Price]*2000)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-RIZ 2000-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-RIZ 3000-5500")

// The change in the probability of choosing the product because of a change in Price from 5000 to 9500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5000) + exp(_b[Price]*9500)) -exp(_b[Price]*5000)/(exp(_b[Price]*5000) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-RIZ 5000-9500")

	// b) Product =="MAIS"
// The change in the probability of choosing the product because of a change in Price from 1200 to 1500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)) -exp(_b[Price]*1200)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MAIS 1200-1500")

// The change in the probability of choosing the product because of a change in Price from 1900 to 2500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)) -exp(_b[Price]*1900)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MAIS 1900-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MAIS 3000-5500")

// The change in the probability of choosing the product because of a change in Price from 5500 to 9500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)) -exp(_b[Price]*5500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MAIS 5500-9500")

	// c) Product =="MANIOC"
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MANIOC 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 1500 to 2040
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*2040)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)) -exp(_b[Price]*1500)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MANIOC 1500-2040")

// The change in the probability of choosing the product because of a change in Price from 2040 to 5000
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*5000)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)) -exp(_b[Price]*2040)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MANIOC 2040-5000")

// The change in the probability of choosing the product because of a change in Price from 5500 to 9500
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)) -exp(_b[Price]*5500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-MANIOC 5500-9500")

	// d) Product =="SUCRE"
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-SUCRE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-SUCRE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-SUCRE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-SUCRE 4500-7000")

	// e) Product =="HUILE"
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="CG", group(obsid)
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-HUILE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="CG", group(obsid)
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-HUILE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="CG", group(obsid)
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-HUILE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
clogit $ModelSpec if Product =="HUILE" & SurveyID=="CG", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("CG-HUILE 4500-7000")


// 2) SurveyID=="IT"
	// a) Product =="RIZ"
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-RIZ 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 2000 to 2500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="IT", group(obsid)  
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)) -exp(_b[Price]*2000)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-RIZ 2000-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-RIZ 3000-5500")


	// b) Product =="MAIS"
// The change in the probability of choosing the product because of a change in Price from 1200 to 1500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)) -exp(_b[Price]*1200)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-MAIS 1200-1500")

// The change in the probability of choosing the product because of a change in Price from 1900 to 2500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)) -exp(_b[Price]*1900)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-MAIS 1900-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-MAIS 3000-5500")

	// c) Product =="MANIOC"
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-MANIOC 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 1500 to 2040
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*2040)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)) -exp(_b[Price]*1500)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-MANIOC 1500-2040")

// The change in the probability of choosing the product because of a change in Price from 2040 to 5000
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*5000)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)) -exp(_b[Price]*2040)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-MANIOC 2040-5000")

// The change in the probability of choosing the product because of a change in Price from 5500 to 9500
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)) -exp(_b[Price]*5500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-MANIOC 5500-9500")

	// d) Product =="SUCRE"
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-SUCRE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-SUCRE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-SUCRE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-SUCRE 4500-7000")

	// e) Product =="HUILE"
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-HUILE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-HUILE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-HUILE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
clogit $ModelSpec if Product =="HUILE" & SurveyID=="IT", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("IT-HUILE 4500-7000")

// 3) SurveyID=="LT" 
	// a) Product =="RIZ"
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-RIZ 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 2000 to 2500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="LT", group(obsid)  
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)) -exp(_b[Price]*2000)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-RIZ 2000-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-RIZ 3000-5500")

// The change in the probability of choosing the product because of a change in Price from 5000 to 9500
clogit $ModelSpec if Product =="RIZ" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5000) + exp(_b[Price]*9500)) -exp(_b[Price]*5000)/(exp(_b[Price]*5000) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-RIZ 5000-9500")

	// b) Product =="MAIS"
// The change in the probability of choosing the product because of a change in Price from 1200 to 1500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)) -exp(_b[Price]*1200)/(exp(_b[Price]*1200) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MAIS 1200-1500")

// The change in the probability of choosing the product because of a change in Price from 1900 to 2500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)) -exp(_b[Price]*1900)/(exp(_b[Price]*1900) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MAIS 1900-2500")

// The change in the probability of choosing the product because of a change in Price from 3000 to 5500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*5500)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)) -exp(_b[Price]*3000)/(exp(_b[Price]*3000) + exp(_b[Price]*5500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MAIS 3000-5500")

// The change in the probability of choosing the product because of a change in Price from 5500 to 9500
clogit $ModelSpec if Product =="MAIS" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)) -exp(_b[Price]*5500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MAIS 5500-9500")


	// c) Product =="MANIOC"
// The change in the probability of choosing the product because of a change in Price from 1000 to 1500
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MANIOC 1000-1500")

// The change in the probability of choosing the product because of a change in Price from 1500 to 2040
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*2040)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)) -exp(_b[Price]*1500)/(exp(_b[Price]*1500) + exp(_b[Price]*2040)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MANIOC 1500-2040")

// The change in the probability of choosing the product because of a change in Price from 2040 to 5000
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*5000)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)) -exp(_b[Price]*2040)/(exp(_b[Price]*2040) + exp(_b[Price]*5000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MANIOC 2040-5000")

// The change in the probability of choosing the product because of a change in Price from 5500 to 9500
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*9500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)) -exp(_b[Price]*5500)/(exp(_b[Price]*5500) + exp(_b[Price]*9500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-MANIOC 5500-9500")


	// d) Product =="SUCRE"
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-SUCRE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-SUCRE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-SUCRE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-SUCRE 4500-7000")


	// e) Product =="HUILE"
// The change in the probability of choosing the product because of a change in Price from 1800 to 2500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-HUILE 1800-2500")

// The change in the probability of choosing the product because of a change in Price from 2500 to 3500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*3500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-HUILE 1900-3500")

// The change in the probability of choosing the product because of a change in Price from 3500 to 4500
clogit $ModelSpec if Product =="HUILE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*4500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)) -exp(_b[Price]*3500)/(exp(_b[Price]*3500) + exp(_b[Price]*4500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-HUILE 3500-4500")

// The change in the probability of choosing the product because of a change in Price from 4500 to 7000
clogit $ModelSpec if Product =="HUILE" & SurveyID=="LT", group(obsid) 
nlcom exp(_b[Price]*7000)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)) -exp(_b[Price]*4500)/(exp(_b[Price]*4500) + exp(_b[Price]*7000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("LT-HUILE 4500-7000")


//==================== New Prices ============================================//
foreach s in CG IT LT {
	// a) Product =="RIZ"
clogit $ModelSpec if Product =="RIZ" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*700)/(exp(_b[Price]*500) + exp(_b[Price]*700)) -exp(_b[Price]*500)/(exp(_b[Price]*500) + exp(_b[Price]*700)), post
outreg2 using UR, stats( coef se ci) se replace label ctitle("`s'-RIZ 500-700")

clogit $ModelSpec if Product =="RIZ" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*900)/(exp(_b[Price]*750) + exp(_b[Price]*900)) -exp(_b[Price]*750)/(exp(_b[Price]*750) + exp(_b[Price]*900)), post
outreg2 using UR, stats( coef se ci) se replace label ctitle("`s'-RIZ 750-900")

clogit $ModelSpec if Product =="RIZ" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1200)/(exp(_b[Price]*950) + exp(_b[Price]*1200)) -exp(_b[Price]*950)/(exp(_b[Price]*950) + exp(_b[Price]*1200)), post
outreg2 using UR, stats( coef se ci) se replace label ctitle("`s'-RIZ 950-1200")

	// b) Product =="MAIS"
clogit $ModelSpec if Product =="MAIS" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*750)/(exp(_b[Price]*500) + exp(_b[Price]*750)) -exp(_b[Price]*500)/(exp(_b[Price]*500) + exp(_b[Price]*750)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MAIS 500-750")

clogit $ModelSpec if Product =="MAIS" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1000)/(exp(_b[Price]*750) + exp(_b[Price]*1000)) -exp(_b[Price]*750)/(exp(_b[Price]*750) + exp(_b[Price]*1000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MAIS 750-1000")

clogit $ModelSpec if Product =="MAIS" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1200)/(exp(_b[Price]*1000) + exp(_b[Price]*1200)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1200)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MAIS 1000-1200")

	// c) Product =="MANIOC"
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*500) + exp(_b[Price]*750)) -exp(_b[Price]*500)/(exp(_b[Price]*500) + exp(_b[Price]*750)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MANIOC 500-750")

clogit $ModelSpec if Product =="MANIOC" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1000)/(exp(_b[Price]*750) + exp(_b[Price]*1000)) -exp(_b[Price]*750)/(exp(_b[Price]*750) + exp(_b[Price]*1000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MANIOC 750-1000")

	// d) Product =="SUCRE"
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*750)/(exp(_b[Price]*500) + exp(_b[Price]*750)) -exp(_b[Price]*500)/(exp(_b[Price]*500) + exp(_b[Price]*750)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 500-750")

clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1000)/(exp(_b[Price]*750) + exp(_b[Price]*1000)) -exp(_b[Price]*750)/(exp(_b[Price]*750) + exp(_b[Price]*1000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 750-1000")

clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1300)/(exp(_b[Price]*1000) + exp(_b[Price]*1300)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1300)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 1000-1300")

clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1300) + exp(_b[Price]*1500)) -exp(_b[Price]*1300)/(exp(_b[Price]*1300) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 1300-1500")

clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1800)/(exp(_b[Price]*1500) + exp(_b[Price]*1800)) -exp(_b[Price]*1500)/(exp(_b[Price]*1500) + exp(_b[Price]*1800)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 1500-1800")

clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*2000)/(exp(_b[Price]*1800) + exp(_b[Price]*2000)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 1800-2000")

clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)) -exp(_b[Price]*2000)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 2000-2500")

clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*3000)/(exp(_b[Price]*2500) + exp(_b[Price]*3000)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE 2500-3000")

	// e) Product =="HUILE"
clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*750)/(exp(_b[Price]*500) + exp(_b[Price]*750)) -exp(_b[Price]*500)/(exp(_b[Price]*500) + exp(_b[Price]*750)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 500-750")

clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1000)/(exp(_b[Price]*750) + exp(_b[Price]*1000)) -exp(_b[Price]*750)/(exp(_b[Price]*750) + exp(_b[Price]*1000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 750-1000")

clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1300)/(exp(_b[Price]*1000) + exp(_b[Price]*1300)) -exp(_b[Price]*1000)/(exp(_b[Price]*1000) + exp(_b[Price]*1300)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 1000-1300")

clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1500)/(exp(_b[Price]*1300) + exp(_b[Price]*1500)) -exp(_b[Price]*1300)/(exp(_b[Price]*1300) + exp(_b[Price]*1500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 1300-1500")

clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*1800)/(exp(_b[Price]*1500) + exp(_b[Price]*1800)) -exp(_b[Price]*1500)/(exp(_b[Price]*1500) + exp(_b[Price]*1800)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 1500-1800")

clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*2000)/(exp(_b[Price]*1800) + exp(_b[Price]*2000)) -exp(_b[Price]*1800)/(exp(_b[Price]*1800) + exp(_b[Price]*2000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 1800-2000")

clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*2500)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)) -exp(_b[Price]*2000)/(exp(_b[Price]*2000) + exp(_b[Price]*2500)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 2000-2500")

clogit $ModelSpec if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom exp(_b[Price]*3000)/(exp(_b[Price]*2500) + exp(_b[Price]*3000)) -exp(_b[Price]*2500)/(exp(_b[Price]*2500) + exp(_b[Price]*3000)), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE 2500-3000")
}

// ------------------------ Packaged products
if $FILE == 1 {
foreach s in CG IT LT {
foreach var in Standard Minimum Moyen Nearby Far {
foreach i in 500 700 750 900 950 1000 1200 1500 2000 2500 3000 5000 5500 9500 {
clogit $ModelSpec if Product =="RIZ" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-RIZ `var'_`i'")
}

foreach i in 500 750 1000 1200 1500 1900 2500 3000 5500 9500 {
clogit $ModelSpec  if Product =="MAIS" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MAIS `var'_`i'")
}

foreach i in 500 750 1000 1500 2040 5000 5500 9500 {
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MANIOC `var'_`i'")
}

foreach i in 500 750 1000 1300 1500 1800 2000 2500 3000 3500 4500 7000 {
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE `var'_`i'")
}

foreach i in 500 750 1000 1300 1500 1800 2000 2500 3000 3500 4500 7000 {
clogit $ModelSpec  if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE `var'_`i'")
}
}
}
}

if $FILE == 2 {
foreach s in CG IT LT {
foreach var in Standard Moyen Far {
foreach i in 500 700 750 900 950 1000 1200 1500 2000 2500 3000 5000 5500 9500 {
clogit $ModelSpec if Product =="RIZ" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-RIZ `var'_`i'")
}

foreach i in 500 750 1000 1200 1500 1900 2500 3000 5500 9500 {
clogit $ModelSpec  if Product =="MAIS" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MAIS `var'_`i'")
}

foreach i in 500 750 1000 1500 2040 5000 5500 9500 {
clogit $ModelSpec if Product =="MANIOC" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-MANIOC `var'_`i'")
}

foreach i in 500 750 1000 1300 1500 1800 2000 2500 3000 3500 4500 7000 {
clogit $ModelSpec if Product =="SUCRE" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-SUCRE `var'_`i'")
}

foreach i in 500 750 1000 1300 1500 1800 2000 2500 3000 3500 4500 7000 {
clogit $ModelSpec  if Product =="HUILE" & SurveyID=="`s'", group(obsid) 
nlcom (exp(_b[Price]*`i'+_b[`var']) - exp(_b[Price]*`i')) /(exp(_b[Price]*`i') + exp(_b[Price]*`i'+_b[`var'])), post
outreg2 using UR, stats( coef se ci) se label ctitle("`s'-HUILE `var'_`i'")
}
}
}
}

import delimited "UR.txt", clear
replace v1="model" in 2
replace v1="b" in 7
replace v1="se" in 8
replace v1="ci" in 9
drop in 1
drop in 2/5
drop in 5
drop in 6/7
drop v2
sxpose, clear
foreach v of varlist * {
rename `v' `=`v'[1]'
}
drop in 1
export excel using "Tables.xlsx", sheet("Table7_2") sheetreplace firstrow(variables)

cap erase UR.txt

